using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using ODT.Common.Core;
using PPPlotControl.Properties;
using ToolTipListBoxNameSpace;

namespace PPPlotControl
{
	public class Form_Process : Form
	{
		public enum ButtonClickEnum
		{
			Update,
			Insert,
			Cancel
		}

		private readonly ILanguageTranslationService languageTranslationService;

		public ArrayList m_store;

		private ButtonClickEnum localButtonClick;

		private IContainer components;

		internal GroupBox GroupBox7;

		internal Label Label35;

		internal ComboBox ComboBox_AvailableItems;

		internal Button button_Process_Close;

		internal TextBox TextBox_Equation;

		internal Label label19;

		internal GroupBox groupBox9;

		internal ComboBox ComboBox_ProcessSource;

		internal TextBox textBox_Scale;

		internal Label label28;

		internal TextBox textBox_Offset;

		internal Label label29;

		internal Label label1;

		internal Button button_Add_AvailableItmes;

		internal Button button_Add_Process;

		internal TextBox TextBox_FunctionName;

		internal Label label2;

		internal Button button_Process_Update;

		internal Button button_Precess_Insert;

		internal Label label3;

		internal Label label4;

		public ButtonClickEnum ButtonClick => localButtonClick;

		public Form_Process(ILanguageTranslationService languageTranslationService)
		{
			this.languageTranslationService = languageTranslationService;
			InitializeComponent();
			base.Icon = Resources.ApplicationIcon;
			base.ShowIcon = true;
			TranslateText();
			m_store = new ArrayList();
			ComboBox_ProcessSource.Items.Add("Add(+)");
			ComboBox_ProcessSource.Items.Add("Sub(-)");
			ComboBox_ProcessSource.Items.Add("Mul(*)");
			ComboBox_ProcessSource.Items.Add("Div(/)");
			ComboBox_ProcessSource.Items.Add("1st_Derivative(d/dt)");
			ComboBox_ProcessSource.Items.Add("2nd_Derivative(d2/dt)");
			ComboBox_ProcessSource.Items.Add("And(&)");
			ComboBox_ProcessSource.Items.Add("Or(|)");
			ComboBox_ProcessSource.SelectedIndex = 0;
		}

		private void AddOperationToArray(string Opr)
		{
			m_store.Add(Opr);
		}

		private void button_Process_Close_Click(object sender, EventArgs e)
		{
			localButtonClick = ButtonClickEnum.Cancel;
		}

		private void button_Add_Process_Click(object sender, EventArgs e)
		{
			if (ComboBox_ProcessSource.SelectedItem.ToString() == "Add(+)")
			{
				TextBox_Equation.Text += " + ";
				TextBox textBox_Equation = TextBox_Equation;
				textBox_Equation.Tag = string.Concat(textBox_Equation.Tag, "+");
				AddOperationToArray("+");
			}
			else if (ComboBox_ProcessSource.SelectedItem.ToString() == "Sub(-)")
			{
				TextBox_Equation.Text += " - ";
				TextBox textBox_Equation2 = TextBox_Equation;
				textBox_Equation2.Tag = string.Concat(textBox_Equation2.Tag, "-");
				AddOperationToArray("-");
			}
			else if (ComboBox_ProcessSource.SelectedItem.ToString() == "Mul(*)")
			{
				TextBox_Equation.Text += " * ";
				TextBox textBox_Equation3 = TextBox_Equation;
				textBox_Equation3.Tag = string.Concat(textBox_Equation3.Tag, "*");
				AddOperationToArray("*");
			}
			else if (ComboBox_ProcessSource.SelectedItem.ToString() == "Div(/)")
			{
				TextBox_Equation.Text += " / ";
				TextBox textBox_Equation4 = TextBox_Equation;
				textBox_Equation4.Tag = string.Concat(textBox_Equation4.Tag, "/");
				AddOperationToArray("/");
			}
			else if (ComboBox_ProcessSource.SelectedItem.ToString() == "1st_Derivative(d/dt)")
			{
				TextBox_Equation.Text = "(d/dt) " + TextBox_Equation.Text;
				TextBox_Equation.Tag = "(d/dt) " + TextBox_Equation.Tag;
				AddOperationToArray("(d/dt)");
			}
			else if (ComboBox_ProcessSource.SelectedItem.ToString() == "2nd_Derivative(d2/dt)")
			{
				TextBox_Equation.Text = "(d2/dt) " + TextBox_Equation.Text;
				TextBox_Equation.Tag = "(d2/dt) " + TextBox_Equation.Tag;
				AddOperationToArray("(d2/dt)");
			}
			else if (ComboBox_ProcessSource.SelectedItem.ToString() == "And(&)")
			{
				TextBox_Equation.Text += " & ";
				TextBox textBox_Equation5 = TextBox_Equation;
				textBox_Equation5.Tag = string.Concat(textBox_Equation5.Tag, "&");
				AddOperationToArray("&");
			}
			else if (ComboBox_ProcessSource.SelectedItem.ToString() == "Or(|)")
			{
				TextBox_Equation.Text += " | ";
				TextBox textBox_Equation6 = TextBox_Equation;
				textBox_Equation6.Tag = string.Concat(textBox_Equation6.Tag, "|");
				AddOperationToArray("|");
			}
			else
			{
				TextBox textBox_Equation7 = TextBox_Equation;
				textBox_Equation7.Text = textBox_Equation7.Text ?? "";
				TextBox textBox_Equation8 = TextBox_Equation;
				textBox_Equation8.Tag = string.Concat(textBox_Equation8.Tag);
			}
		}

		private void button_Add_AvailableItmes_Click(object sender, EventArgs e)
		{
			if (ComboBox_AvailableItems.SelectedIndex > -1)
			{
				SourceList sourceList = (SourceList)ComboBox_AvailableItems.SelectedItem;
				TextBox_Equation.Text += sourceList.SValue.ToString();
				TextBox textBox_Equation = TextBox_Equation;
				textBox_Equation.Tag = string.Concat(textBox_Equation.Tag, ComboBox_AvailableItems.SelectedItem.ToString());
				AddOperationToArray(sourceList.SValue.ToString());
			}
		}

		private void button_Precess_Insert_Click(object sender, EventArgs e)
		{
			localButtonClick = ButtonClickEnum.Insert;
			Close();
		}

		private void button_Process_Update_Click(object sender, EventArgs e)
		{
			localButtonClick = ButtonClickEnum.Update;
			Close();
		}

		private void TranslateText()
		{
			SuspendLayout();
			string text = languageTranslationService.Translate("PlotControl.OffsetText");
			string text2 = languageTranslationService.Translate("PlotControl.ScaleFactorText");
			string text3 = languageTranslationService.Translate("Common.Add");
			GroupBox7.Text = languageTranslationService.Translate("PlotControl.DataProcessingText");
			label4.Text = " ) + " + text;
			label3.Text = text2 + " * ( ";
			button_Precess_Insert.Text = languageTranslationService.Translate("PlotControl.InsertText");
			button_Process_Update.Text = languageTranslationService.Translate("PlotControl.UpdateText");
			label2.Text = languageTranslationService.Translate("PlotControl.FunctionNameText") + " F(x) = ";
			button_Add_AvailableItmes.Text = text3;
			button_Add_Process.Text = text3;
			label1.Text = languageTranslationService.Translate("PlotControl.AvailableProcessText");
			Label35.Text = languageTranslationService.Translate("PlotControl.AvailableItemsText");
			ComboBox_ProcessSource.Text = text3;
			button_Process_Close.Text = languageTranslationService.Translate("Common.Cancel");
			label19.Text = languageTranslationService.Translate("PlotControl.ProcessText") + "  = ";
			groupBox9.Text = languageTranslationService.Translate("PlotControl.ScaleAndOffsetText");
			label28.Text = text2;
			label29.Text = text;
			Text = languageTranslationService.Translate("PlotControl.ProcessDataText");
			ResumeLayout(false);
		}

		protected override void Dispose(bool disposing)
		{
			if (disposing && components != null)
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}

		private void InitializeComponent()
		{
			this.GroupBox7 = new System.Windows.Forms.GroupBox();
			this.label4 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.button_Precess_Insert = new System.Windows.Forms.Button();
			this.button_Process_Update = new System.Windows.Forms.Button();
			this.TextBox_FunctionName = new System.Windows.Forms.TextBox();
			this.label2 = new System.Windows.Forms.Label();
			this.button_Add_AvailableItmes = new System.Windows.Forms.Button();
			this.button_Add_Process = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.Label35 = new System.Windows.Forms.Label();
			this.ComboBox_ProcessSource = new System.Windows.Forms.ComboBox();
			this.ComboBox_AvailableItems = new System.Windows.Forms.ComboBox();
			this.button_Process_Close = new System.Windows.Forms.Button();
			this.TextBox_Equation = new System.Windows.Forms.TextBox();
			this.label19 = new System.Windows.Forms.Label();
			this.groupBox9 = new System.Windows.Forms.GroupBox();
			this.textBox_Scale = new System.Windows.Forms.TextBox();
			this.label28 = new System.Windows.Forms.Label();
			this.textBox_Offset = new System.Windows.Forms.TextBox();
			this.label29 = new System.Windows.Forms.Label();
			this.GroupBox7.SuspendLayout();
			this.groupBox9.SuspendLayout();
			base.SuspendLayout();
			this.GroupBox7.Controls.Add(this.label4);
			this.GroupBox7.Controls.Add(this.label3);
			this.GroupBox7.Controls.Add(this.button_Precess_Insert);
			this.GroupBox7.Controls.Add(this.button_Process_Update);
			this.GroupBox7.Controls.Add(this.TextBox_FunctionName);
			this.GroupBox7.Controls.Add(this.label2);
			this.GroupBox7.Controls.Add(this.button_Add_AvailableItmes);
			this.GroupBox7.Controls.Add(this.button_Add_Process);
			this.GroupBox7.Controls.Add(this.label1);
			this.GroupBox7.Controls.Add(this.Label35);
			this.GroupBox7.Controls.Add(this.ComboBox_ProcessSource);
			this.GroupBox7.Controls.Add(this.ComboBox_AvailableItems);
			this.GroupBox7.Controls.Add(this.button_Process_Close);
			this.GroupBox7.Controls.Add(this.TextBox_Equation);
			this.GroupBox7.Controls.Add(this.label19);
			this.GroupBox7.Location = new System.Drawing.Point(164, 21);
			this.GroupBox7.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
			this.GroupBox7.Name = "GroupBox7";
			this.GroupBox7.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
			this.GroupBox7.Size = new System.Drawing.Size(603, 266);
			this.GroupBox7.TabIndex = 33;
			this.GroupBox7.TabStop = false;
			this.GroupBox7.Text = "Data Processing";
			this.label4.AutoSize = true;
			this.label4.Location = new System.Drawing.Point(521, 84);
			this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(71, 17);
			this.label4.TabIndex = 22;
			this.label4.Text = " ) + Offset";
			this.label3.AutoSize = true;
			this.label3.Location = new System.Drawing.Point(81, 84);
			this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(109, 17);
			this.label3.TabIndex = 22;
			this.label3.Text = "Scale Factor * ( ";
			this.button_Precess_Insert.Location = new System.Drawing.Point(72, 202);
			this.button_Precess_Insert.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
			this.button_Precess_Insert.Name = "button_Precess_Insert";
			this.button_Precess_Insert.Size = new System.Drawing.Size(136, 44);
			this.button_Precess_Insert.TabIndex = 34;
			this.button_Precess_Insert.Text = "Insert";
			this.button_Precess_Insert.UseVisualStyleBackColor = true;
			this.button_Precess_Insert.Click += new System.EventHandler(button_Precess_Insert_Click);
			this.button_Process_Update.Location = new System.Drawing.Point(216, 202);
			this.button_Process_Update.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
			this.button_Process_Update.Name = "button_Process_Update";
			this.button_Process_Update.Size = new System.Drawing.Size(136, 44);
			this.button_Process_Update.TabIndex = 33;
			this.button_Process_Update.Text = "Update";
			this.button_Process_Update.UseVisualStyleBackColor = true;
			this.button_Process_Update.Click += new System.EventHandler(button_Process_Update_Click);
			this.TextBox_FunctionName.AutoCompleteCustomSource.AddRange(new string[4] { "Motor", "Cmd", "Act", "Gain" });
			this.TextBox_FunctionName.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
			this.TextBox_FunctionName.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource;
			this.TextBox_FunctionName.Location = new System.Drawing.Point(198, 48);
			this.TextBox_FunctionName.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
			this.TextBox_FunctionName.Name = "TextBox_FunctionName";
			this.TextBox_FunctionName.Size = new System.Drawing.Size(314, 22);
			this.TextBox_FunctionName.TabIndex = 31;
			this.label2.AutoSize = true;
			this.label2.Location = new System.Drawing.Point(3, 50);
			this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(147, 17);
			this.label2.TabIndex = 32;
			this.label2.Text = "Function Name F(x) = ";
			this.button_Add_AvailableItmes.Location = new System.Drawing.Point(443, 150);
			this.button_Add_AvailableItmes.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
			this.button_Add_AvailableItmes.Name = "button_Add_AvailableItmes";
			this.button_Add_AvailableItmes.Size = new System.Drawing.Size(53, 30);
			this.button_Add_AvailableItmes.TabIndex = 30;
			this.button_Add_AvailableItmes.Text = "Add";
			this.button_Add_AvailableItmes.UseVisualStyleBackColor = true;
			this.button_Add_AvailableItmes.Click += new System.EventHandler(button_Add_AvailableItmes_Click);
			this.button_Add_Process.Location = new System.Drawing.Point(443, 118);
			this.button_Add_Process.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
			this.button_Add_Process.Name = "button_Add_Process";
			this.button_Add_Process.Size = new System.Drawing.Size(53, 30);
			this.button_Add_Process.TabIndex = 29;
			this.button_Add_Process.Text = "Add";
			this.button_Add_Process.UseVisualStyleBackColor = true;
			this.button_Add_Process.Click += new System.EventHandler(button_Add_Process_Click);
			this.label1.AutoSize = true;
			this.label1.Location = new System.Drawing.Point(83, 122);
			this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(124, 17);
			this.label1.TabIndex = 28;
			this.label1.Text = "Available Process:";
			this.Label35.AutoSize = true;
			this.Label35.Location = new System.Drawing.Point(87, 155);
			this.Label35.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
			this.Label35.Name = "Label35";
			this.Label35.Size = new System.Drawing.Size(106, 17);
			this.Label35.TabIndex = 15;
			this.Label35.Text = "Available Items:";
			this.ComboBox_ProcessSource.FormattingEnabled = true;
			this.ComboBox_ProcessSource.Location = new System.Drawing.Point(213, 118);
			this.ComboBox_ProcessSource.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
			this.ComboBox_ProcessSource.Name = "ComboBox_ProcessSource";
			this.ComboBox_ProcessSource.Size = new System.Drawing.Size(219, 24);
			this.ComboBox_ProcessSource.TabIndex = 27;
			this.ComboBox_ProcessSource.Text = "Add";
			this.ComboBox_AvailableItems.FormattingEnabled = true;
			this.ComboBox_AvailableItems.Location = new System.Drawing.Point(213, 151);
			this.ComboBox_AvailableItems.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
			this.ComboBox_AvailableItems.Name = "ComboBox_AvailableItems";
			this.ComboBox_AvailableItems.Size = new System.Drawing.Size(219, 24);
			this.ComboBox_AvailableItems.TabIndex = 14;
			this.button_Process_Close.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.button_Process_Close.Location = new System.Drawing.Point(360, 202);
			this.button_Process_Close.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
			this.button_Process_Close.Name = "button_Process_Close";
			this.button_Process_Close.Size = new System.Drawing.Size(136, 44);
			this.button_Process_Close.TabIndex = 11;
			this.button_Process_Close.Text = "Cancel";
			this.button_Process_Close.UseVisualStyleBackColor = true;
			this.button_Process_Close.Click += new System.EventHandler(button_Process_Close_Click);
			this.TextBox_Equation.AutoCompleteCustomSource.AddRange(new string[4] { "Motor", "Cmd", "Act", "Gain" });
			this.TextBox_Equation.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
			this.TextBox_Equation.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource;
			this.TextBox_Equation.Location = new System.Drawing.Point(198, 80);
			this.TextBox_Equation.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
			this.TextBox_Equation.Name = "TextBox_Equation";
			this.TextBox_Equation.Size = new System.Drawing.Size(314, 22);
			this.TextBox_Equation.TabIndex = 4;
			this.label19.AutoSize = true;
			this.label19.Location = new System.Drawing.Point(3, 84);
			this.label19.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
			this.label19.Name = "label19";
			this.label19.Size = new System.Drawing.Size(79, 17);
			this.label19.TabIndex = 10;
			this.label19.Text = "Process  = ";
			this.groupBox9.Controls.Add(this.textBox_Scale);
			this.groupBox9.Controls.Add(this.label28);
			this.groupBox9.Controls.Add(this.textBox_Offset);
			this.groupBox9.Controls.Add(this.label29);
			this.groupBox9.Location = new System.Drawing.Point(12, 21);
			this.groupBox9.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
			this.groupBox9.Name = "groupBox9";
			this.groupBox9.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
			this.groupBox9.Size = new System.Drawing.Size(144, 266);
			this.groupBox9.TabIndex = 31;
			this.groupBox9.TabStop = false;
			this.groupBox9.Text = "Scale and Offset";
			this.textBox_Scale.Location = new System.Drawing.Point(16, 52);
			this.textBox_Scale.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
			this.textBox_Scale.Name = "textBox_Scale";
			this.textBox_Scale.Size = new System.Drawing.Size(101, 22);
			this.textBox_Scale.TabIndex = 17;
			this.textBox_Scale.Text = "1";
			this.label28.AutoSize = true;
			this.label28.Location = new System.Drawing.Point(12, 32);
			this.label28.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
			this.label28.Name = "label28";
			this.label28.Size = new System.Drawing.Size(87, 17);
			this.label28.TabIndex = 18;
			this.label28.Text = "Scale Factor";
			this.textBox_Offset.Location = new System.Drawing.Point(16, 135);
			this.textBox_Offset.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
			this.textBox_Offset.Name = "textBox_Offset";
			this.textBox_Offset.Size = new System.Drawing.Size(101, 22);
			this.textBox_Offset.TabIndex = 20;
			this.textBox_Offset.Text = "0";
			this.label29.AutoSize = true;
			this.label29.Location = new System.Drawing.Point(12, 116);
			this.label29.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
			this.label29.Name = "label29";
			this.label29.Size = new System.Drawing.Size(46, 17);
			this.label29.TabIndex = 21;
			this.label29.Text = "Offset";
			base.AcceptButton = this.button_Process_Close;
			base.AutoScaleDimensions = new System.Drawing.SizeF(8f, 16f);
			base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			base.ClientSize = new System.Drawing.Size(783, 311);
			base.Controls.Add(this.GroupBox7);
			base.Controls.Add(this.groupBox9);
			base.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
			base.Name = "Form_Process";
			this.Text = "Process Data";
			this.GroupBox7.ResumeLayout(false);
			this.GroupBox7.PerformLayout();
			this.groupBox9.ResumeLayout(false);
			this.groupBox9.PerformLayout();
			base.ResumeLayout(false);
		}
	}
}
